#include <iostream>
#include <string>
using namespace std;

template<typename T>
struct Clonable {
    ~Clonable() {
        T (T::*ptr)() const = &T::clonable;
        ptr;
    }
};

class FirstClass1 : public Clonable<FirstClass1> {
    public:
        FirstClass1 clonable() const {
            cout << "clonable" << endl;
            return FirstClass1();
        }
};

/*class SecondClass : public Clonable<SecondClass> {
    public:
        int test() const {
            return 33;
        }
};*/

template<typename T>
struct MakeCopy {
    T operator()(const T& t) const {
        return T(t);
    }
};

template<typename T>
struct MakeCopy<Clonable<T> > {
    T operator()(const T& m) const {
        return m.clonable();
    }
};

int main() {
    string s1("string");
    MakeCopy<string> m1;
    string s2 = m1(s1);
    FirstClass1 f1;
    MakeCopy<Clonable<FirstClass1> > m2;
    FirstClass1 f2 = m2(f1);
    //SecondClass s;*/
    return 0;
}
